// 须在W3C DTD下使用 否测请修改高度算法

function cike(title,content,width,height){

  var temp_float=new String;
  temp_float="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
  temp_float+="<div id=\"floatBox\" style=\"height:"+height+"px;width:"+width+"px;filter:alpha(opacity=0);opacity:0;\">";
  temp_float+="<div id=\"floatBoxbar\"><h4></h4><span>关闭</span></div>";
  temp_float+="<div id=\"floatBoxbody\"></div>";
  temp_float+="</div>";
  $("body").append(temp_float);



$("#floatBoxbar span").click(function(){
   $("#floatBox").animate({opacity:"0"},"normal",function(){$(this).remove();$("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).remove();});});
});

$("#floatBoxBg").click(function(){
	$("#floatBox").animate({opacity:"0"},"normal",function(){$(this).remove();$("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).remove();});});
});

$("#floatBoxbar h4").html(title);

contentType=content.substring(0,content.indexOf(":"));
content=content.substring(content.indexOf(":")+1,content.length);
switch(contentType){
  case "url":
  var content_array=content.split("?");
  $("#floatBoxbody").ajaxStart(function(){
    $(this).html("loading...");
  });
  $.ajax({
    type:content_array[0],
    url:content_array[1],
    data:content_array[2],
	error:function(){
	  $("#floatBoxbody").html("error...");
	},
    success:function(html){
      $("#floatBoxbody").html(html);
    }
  });
  break;
  case "text":
  $("#floatBoxbody").html(content);
  break;
  case "id":
  $("#floatBoxbody").html($("#"+content+"").html());
  break;
  case "iframe":
  $("#floatBoxbody").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
}

var _clientHeight=(window.opera)?$(window).height():document.documentElement.clientHeight;

//$(window).height() 支怪癖模式 不支持标准下的OPera   documentElement.clientHeight 不支持怪癖下的IE FF
//alert(_clientHeight);
//alert($(window).height()+"\n"+parseInt(parseInt(height)+0)+"\n"+(height=="auto"?50:(_clientHeight>(parseInt(height)+30)?(_clientHeight-height)/2-30:0))+"\n"+height);
$("#floatBox").css({
				   left: ($(window).width()-parseInt(width) )/2+"px",
				   top:$(document).scrollTop()+(height=="auto"?50:(document.documentElement.clientHeight>(parseInt(height)+30)?(document.documentElement.clientHeight-height)/2-30:0))+"px"
				   //中线向上偏移30px
				   });
					
//$("#floatBox").css({left:(($(document).width())/2-(parseInt(width)/2))+"px",top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px",width:width,height:height});
//$("#floatBox").animate({top:($(document).scrollTop()+50)+"px"},"normal"); 
$("#floatBoxBg").animate({opacity:"0.5"},"normal",function(){$("#floatBox").animate({opacity:"1"},"normal");});

}